<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/****************************************************************************
<span class='line'>  2</span>  Copyright (c) 2010-2012 cocos2d-x.org
<span class='line'>  3</span>  Copyright (c) 2008-2010 Ricardo Quesada
<span class='line'>  4</span>  Copyright (c) 2011      Zynga Inc.
<span class='line'>  5</span> 
<span class='line'>  6</span>  http://www.cocos2d-x.org
<span class='line'>  7</span> 
<span class='line'>  8</span>  Permission is hereby granted, free of charge, to any person obtaining a copy
<span class='line'>  9</span>  of this software and associated documentation files (the "Software"), to deal
<span class='line'> 10</span>  in the Software without restriction, including without limitation the rights
<span class='line'> 11</span>  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
<span class='line'> 12</span>  copies of the Software, and to permit persons to whom the Software is
<span class='line'> 13</span>  furnished to do so, subject to the following conditions:
<span class='line'> 14</span> 
<span class='line'> 15</span>  The above copyright notice and this permission notice shall be included in
<span class='line'> 16</span>  all copies or substantial portions of the Software.
<span class='line'> 17</span> 
<span class='line'> 18</span>  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
<span class='line'> 19</span>  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
<span class='line'> 20</span>  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
<span class='line'> 21</span>  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
<span class='line'> 22</span>  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
<span class='line'> 23</span>  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
<span class='line'> 24</span>  THE SOFTWARE.
<span class='line'> 25</span>  ****************************************************************************/</span><span class="WHIT">
<span class='line'> 26</span> 
<span class='line'> 27</span> </span><span class="COMM">/**
<span class='line'> 28</span>  * android back button
<span class='line'> 29</span>  * @deprecated These were for android devices, but does not work in html5 environment
<span class='line'> 30</span>  * @constant
<span class='line'> 31</span>  * @type Number
<span class='line'> 32</span>  */</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="NAME">cc.TYPE_BACK_CLICKED</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="COMM">/**
<span class='line'> 35</span>  * android menu button
<span class='line'> 36</span>  * @deprecated for android devices, does not work in html5 environment
<span class='line'> 37</span>  * @constant
<span class='line'> 38</span>  * @type Number
<span class='line'> 39</span>  */</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="NAME">cc.TYPE_MENU_CLICKED</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="COMM">/**
<span class='line'> 42</span>  * keymap
<span class='line'> 43</span>  * @example
<span class='line'> 44</span>  * //Example
<span class='line'> 45</span>  * //to mark a keydown
<span class='line'> 46</span>  * cc.keyDown[65] = true;
<span class='line'> 47</span>  * //or
<span class='line'> 48</span>  * cc.keyMap[cc.KEY.a]
<span class='line'> 49</span>  *
<span class='line'> 50</span>  * //to mark a keyup
<span class='line'> 51</span>  * do cc.keyDown[65] = false;
<span class='line'> 52</span>  *
<span class='line'> 53</span>  * //to find out if a key is down, check
<span class='line'> 54</span>  * if(cc.keyDown[65])
<span class='line'> 55</span>  * //or
<span class='line'> 56</span>  * if,(cc.keyDown[cc.KEY.space])
<span class='line'> 57</span>  * //if its undefined or false or null, its not pressed
<span class='line'> 58</span>  * @constant
<span class='line'> 59</span>  * @type object
<span class='line'> 60</span>  */</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="NAME">cc.KEY</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">    </span><span class="NAME">backspace</span><span class="PUNC">:</span><span class="NUMB">8</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">    </span><span class="NAME">tab</span><span class="PUNC">:</span><span class="NUMB">9</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">    </span><span class="NAME">enter</span><span class="PUNC">:</span><span class="NUMB">13</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">    </span><span class="NAME">shift</span><span class="PUNC">:</span><span class="NUMB">16</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">//should use shiftkey instead</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">    </span><span class="NAME">ctrl</span><span class="PUNC">:</span><span class="NUMB">17</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">//should use ctrlkey</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">    </span><span class="NAME">alt</span><span class="PUNC">:</span><span class="NUMB">18</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">//should use altkey</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">    </span><span class="NAME">pause</span><span class="PUNC">:</span><span class="NUMB">19</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT">    </span><span class="NAME">capslock</span><span class="PUNC">:</span><span class="NUMB">20</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">    </span><span class="NAME">escape</span><span class="PUNC">:</span><span class="NUMB">27</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">    </span><span class="NAME">pageup</span><span class="PUNC">:</span><span class="NUMB">33</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">    </span><span class="NAME">pagedown</span><span class="PUNC">:</span><span class="NUMB">34</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">    </span><span class="NAME">end</span><span class="PUNC">:</span><span class="NUMB">35</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">    </span><span class="NAME">home</span><span class="PUNC">:</span><span class="NUMB">36</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">    </span><span class="NAME">left</span><span class="PUNC">:</span><span class="NUMB">37</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">    </span><span class="NAME">up</span><span class="PUNC">:</span><span class="NUMB">38</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">    </span><span class="NAME">right</span><span class="PUNC">:</span><span class="NUMB">39</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">    </span><span class="NAME">down</span><span class="PUNC">:</span><span class="NUMB">40</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">    </span><span class="NAME">insert</span><span class="PUNC">:</span><span class="NUMB">45</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">    </span><span class="NAME">Delete</span><span class="PUNC">:</span><span class="NUMB">46</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">    </span><span class="NUMB">0</span><span class="PUNC">:</span><span class="NUMB">48</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">    </span><span class="NUMB">1</span><span class="PUNC">:</span><span class="NUMB">49</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">    </span><span class="NUMB">2</span><span class="PUNC">:</span><span class="NUMB">50</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">    </span><span class="NUMB">3</span><span class="PUNC">:</span><span class="NUMB">51</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">    </span><span class="NUMB">4</span><span class="PUNC">:</span><span class="NUMB">52</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">    </span><span class="NUMB">5</span><span class="PUNC">:</span><span class="NUMB">53</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">    </span><span class="NUMB">6</span><span class="PUNC">:</span><span class="NUMB">54</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">    </span><span class="NUMB">7</span><span class="PUNC">:</span><span class="NUMB">55</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">    </span><span class="NUMB">8</span><span class="PUNC">:</span><span class="NUMB">56</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">    </span><span class="NUMB">9</span><span class="PUNC">:</span><span class="NUMB">57</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">    </span><span class="NAME">a</span><span class="PUNC">:</span><span class="NUMB">65</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">    </span><span class="NAME">b</span><span class="PUNC">:</span><span class="NUMB">66</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">    </span><span class="NAME">c</span><span class="PUNC">:</span><span class="NUMB">67</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">    </span><span class="NAME">d</span><span class="PUNC">:</span><span class="NUMB">68</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">    </span><span class="NAME">e</span><span class="PUNC">:</span><span class="NUMB">69</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">    </span><span class="NAME">f</span><span class="PUNC">:</span><span class="NUMB">70</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">    </span><span class="NAME">g</span><span class="PUNC">:</span><span class="NUMB">71</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">    </span><span class="NAME">h</span><span class="PUNC">:</span><span class="NUMB">72</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">    </span><span class="NAME">i</span><span class="PUNC">:</span><span class="NUMB">73</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">    </span><span class="NAME">j</span><span class="PUNC">:</span><span class="NUMB">74</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">    </span><span class="NAME">k</span><span class="PUNC">:</span><span class="NUMB">75</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">    </span><span class="NAME">l</span><span class="PUNC">:</span><span class="NUMB">76</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">    </span><span class="NAME">m</span><span class="PUNC">:</span><span class="NUMB">77</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">    </span><span class="NAME">n</span><span class="PUNC">:</span><span class="NUMB">78</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">    </span><span class="NAME">o</span><span class="PUNC">:</span><span class="NUMB">79</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">    </span><span class="NAME">p</span><span class="PUNC">:</span><span class="NUMB">80</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">    </span><span class="NAME">q</span><span class="PUNC">:</span><span class="NUMB">81</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">    </span><span class="NAME">r</span><span class="PUNC">:</span><span class="NUMB">82</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">    </span><span class="NAME">s</span><span class="PUNC">:</span><span class="NUMB">83</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">    </span><span class="NAME">t</span><span class="PUNC">:</span><span class="NUMB">84</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">    </span><span class="NAME">u</span><span class="PUNC">:</span><span class="NUMB">85</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">    </span><span class="NAME">v</span><span class="PUNC">:</span><span class="NUMB">86</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">    </span><span class="NAME">w</span><span class="PUNC">:</span><span class="NUMB">87</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">    </span><span class="NAME">x</span><span class="PUNC">:</span><span class="NUMB">88</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">    </span><span class="NAME">y</span><span class="PUNC">:</span><span class="NUMB">89</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">    </span><span class="NAME">z</span><span class="PUNC">:</span><span class="NUMB">90</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">    </span><span class="NAME">num0</span><span class="PUNC">:</span><span class="NUMB">96</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">    </span><span class="NAME">num1</span><span class="PUNC">:</span><span class="NUMB">97</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">    </span><span class="NAME">num2</span><span class="PUNC">:</span><span class="NUMB">98</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">    </span><span class="NAME">num3</span><span class="PUNC">:</span><span class="NUMB">99</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">    </span><span class="NAME">num4</span><span class="PUNC">:</span><span class="NUMB">100</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">    </span><span class="NAME">num5</span><span class="PUNC">:</span><span class="NUMB">101</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">    </span><span class="NAME">num6</span><span class="PUNC">:</span><span class="NUMB">102</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">    </span><span class="NAME">num7</span><span class="PUNC">:</span><span class="NUMB">103</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">    </span><span class="NAME">num8</span><span class="PUNC">:</span><span class="NUMB">104</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">    </span><span class="NAME">num9</span><span class="PUNC">:</span><span class="NUMB">105</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">    </span><span class="STRN">'*'</span><span class="PUNC">:</span><span class="NUMB">106</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">    </span><span class="STRN">'+'</span><span class="PUNC">:</span><span class="NUMB">107</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">    </span><span class="STRN">'-'</span><span class="PUNC">:</span><span class="NUMB">109</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">    </span><span class="STRN">'numdel'</span><span class="PUNC">:</span><span class="NUMB">110</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">    </span><span class="STRN">'/'</span><span class="PUNC">:</span><span class="NUMB">111</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">    </span><span class="NAME">f1</span><span class="PUNC">:</span><span class="NUMB">112</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">//f1-f12 dont work on ie</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">    </span><span class="NAME">f2</span><span class="PUNC">:</span><span class="NUMB">113</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">    </span><span class="NAME">f3</span><span class="PUNC">:</span><span class="NUMB">114</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">    </span><span class="NAME">f4</span><span class="PUNC">:</span><span class="NUMB">115</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">    </span><span class="NAME">f5</span><span class="PUNC">:</span><span class="NUMB">116</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">    </span><span class="NAME">f6</span><span class="PUNC">:</span><span class="NUMB">117</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">    </span><span class="NAME">f7</span><span class="PUNC">:</span><span class="NUMB">118</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">    </span><span class="NAME">f8</span><span class="PUNC">:</span><span class="NUMB">119</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">    </span><span class="NAME">f9</span><span class="PUNC">:</span><span class="NUMB">120</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">    </span><span class="NAME">f10</span><span class="PUNC">:</span><span class="NUMB">121</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">    </span><span class="NAME">f11</span><span class="PUNC">:</span><span class="NUMB">122</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">    </span><span class="NAME">f12</span><span class="PUNC">:</span><span class="NUMB">123</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">    </span><span class="NAME">numlock</span><span class="PUNC">:</span><span class="NUMB">144</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">    </span><span class="NAME">scrolllock</span><span class="PUNC">:</span><span class="NUMB">145</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">    </span><span class="NAME">semicolon</span><span class="PUNC">:</span><span class="NUMB">186</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">    </span><span class="STRN">','</span><span class="PUNC">:</span><span class="NUMB">186</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">    </span><span class="NAME">equal</span><span class="PUNC">:</span><span class="NUMB">187</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">    </span><span class="STRN">'='</span><span class="PUNC">:</span><span class="NUMB">187</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">    </span><span class="STRN">';'</span><span class="PUNC">:</span><span class="NUMB">188</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">    </span><span class="NAME">comma</span><span class="PUNC">:</span><span class="NUMB">188</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">    </span><span class="NAME">dash</span><span class="PUNC">:</span><span class="NUMB">189</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">    </span><span class="STRN">'.'</span><span class="PUNC">:</span><span class="NUMB">190</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">    </span><span class="NAME">period</span><span class="PUNC">:</span><span class="NUMB">190</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">    </span><span class="NAME">forwardslash</span><span class="PUNC">:</span><span class="NUMB">191</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">    </span><span class="NAME">grave</span><span class="PUNC">:</span><span class="NUMB">192</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">    </span><span class="STRN">'['</span><span class="PUNC">:</span><span class="NUMB">219</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">    </span><span class="NAME">openbracket</span><span class="PUNC">:</span><span class="NUMB">219</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">    </span><span class="STRN">']'</span><span class="PUNC">:</span><span class="NUMB">221</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">    </span><span class="NAME">closebracket</span><span class="PUNC">:</span><span class="NUMB">221</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">    </span><span class="NAME">backslash</span><span class="PUNC">:</span><span class="NUMB">220</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">    </span><span class="NAME">quote</span><span class="PUNC">:</span><span class="NUMB">222</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">    </span><span class="NAME">space</span><span class="PUNC">:</span><span class="NUMB">32</span><span class="WHIT">
<span class='line'>164</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>165</span> 
<span class='line'>166</span> </span><span class="COMM">/**
<span class='line'>167</span>  * Dispatch the keyboard message
<span class='line'>168</span>  * @class
<span class='line'>169</span>  * @extends cc.Class
<span class='line'>170</span>  */</span><span class="WHIT">
<span class='line'>171</span> </span><span class="NAME">cc.KeyboardDispatcher</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">cc.Class.extend</span><span class="PUNC">(</span><span class="COMM">/** @lends cc.KeyboardDispatcher# */</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>172</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>173</span>      * add delegate to concern keyboard msg
<span class='line'>174</span>      * @param {cc.KeyboardDelegate} delegate keyboard delegate object
<span class='line'>175</span>      */</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">    </span><span class="NAME">addDelegate</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>177</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>178</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this._locked</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">            </span><span class="NAME">this.forceAddDelegate</span><span class="PUNC">(</span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">        </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">            </span><span class="NAME">this._handlersToAdd.push</span><span class="PUNC">(</span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">            </span><span class="NAME">this._toAdd</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>188</span> 
<span class='line'>189</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>190</span>      * remove the delegate from the delegates who concern keyboard msg
<span class='line'>191</span>      * @param {cc.KeyboardDelegate} delegate
<span class='line'>192</span>      */</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">    </span><span class="NAME">removeDelegate</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">this._locked</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">            </span><span class="NAME">this.forceRemoveDelegate</span><span class="PUNC">(</span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">        </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">            </span><span class="NAME">this._handlersToRemove.push</span><span class="PUNC">(</span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">            </span><span class="NAME">this._toRemove</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>205</span> 
<span class='line'>206</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>207</span>      * force add the delegate
<span class='line'>208</span>      * @param {cc.KeyboardDelegate} delegate
<span class='line'>209</span>      */</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">    </span><span class="NAME">forceAddDelegate</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">handler</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">cc.KeyboardHandler.create</span><span class="PUNC">(</span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">handler</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">            </span><span class="COMM">//if handler already exist</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">            </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">this._delegates</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this._delegates</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getDelegate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">handler.getDelegate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>218</span> </span><span class="WHIT">            </span><span class="NAME">this._delegates.push</span><span class="PUNC">(</span><span class="NAME">handler</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>221</span> 
<span class='line'>222</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>223</span>      * force remove the delegate
<span class='line'>224</span>      * @param {cc.KeyboardDelegate} delegate
<span class='line'>225</span>      */</span><span class="WHIT">
<span class='line'>226</span> </span><span class="WHIT">    </span><span class="NAME">forceRemoveDelegate</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>227</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">this._delegates.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>228</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this._delegates</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getDelegate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">delegate</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>229</span> </span><span class="WHIT">                </span><span class="NAME">this._delegates.splice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>230</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>234</span> 
<span class='line'>235</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>236</span>      * dispatch the keyboard message to the delegates
<span class='line'>237</span>      * @param {event} e
<span class='line'>238</span>      * @param {Boolean} keydown whether this is a keydown or keyup
<span class='line'>239</span>      * @return {Boolean}
<span class='line'>240</span>      */</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">    </span><span class="NAME">dispatchKeyboardMSG</span><span class="PUNC">:</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keydown</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">        </span><span class="NAME">this._locked</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">        </span><span class="NAME">e.stopPropagation</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">        </span><span class="NAME">e.preventDefault</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>245</span> 
<span class='line'>246</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">        </span><span class="COMM">//update keymap</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">keydown</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">     </span><span class="COMM">//if keydown and our keymap doesnt have it</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT">            </span><span class="COMM">//execute all deletegate that registered a keyboard event</span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT">            </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">this._delegates.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">this._delegates</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getDelegate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this._delegates</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getDelegate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">onKeyDown</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">                    </span><span class="NAME">this._delegates</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getDelegate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">onKeyDown</span><span class="PUNC">(</span><span class="NAME">e.keyCode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">  </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">keydown</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="COMM">//if keyup and our keymap have that key in it</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">            </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">this._delegates.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">this._delegates</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getDelegate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">this._delegates</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getDelegate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">onKeyUp</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">                    </span><span class="NAME">this._delegates</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getDelegate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">onKeyUp</span><span class="PUNC">(</span><span class="NAME">e.keyCode</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">        </span><span class="NAME">this._locked</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this._toRemove</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">            </span><span class="NAME">this._toRemove</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">            </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">this._handlersToRemove.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>264</span> </span><span class="WHIT">                </span><span class="NAME">this.forceRemoveDelegate</span><span class="PUNC">(</span><span class="NAME">this._handlersToRemove</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>265</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">            </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">this._handlersToRemove</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">            </span><span class="NAME">this._handlersToRemove</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>269</span> 
<span class='line'>270</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this._toAdd</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">            </span><span class="NAME">this._toAdd</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">            </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">this._handlersToAdd.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">                </span><span class="NAME">this.forceAddDelegate</span><span class="PUNC">(</span><span class="NAME">this._handlersToAdd</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">            </span><span class="NAME">this._handlersToAdd</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>279</span> 
<span class='line'>280</span> </span><span class="WHIT">    </span><span class="COMM">//private</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">    </span><span class="NAME">_delegates</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT">    </span><span class="NAME">_locked</span><span class="PUNC">:</span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">    </span><span class="NAME">_toAdd</span><span class="PUNC">:</span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">    </span><span class="NAME">_toRemove</span><span class="PUNC">:</span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">    </span><span class="NAME">_handlersToAdd</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT">    </span><span class="NAME">_handlersToRemove</span><span class="PUNC">:</span><span class="PUNC">[</span><span class="PUNC">]</span><span class="WHIT">
<span class='line'>287</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>288</span> 
<span class='line'>289</span> </span><span class="COMM">/**
<span class='line'>290</span>  * Returns the shared cc.KeyboardDispatcher object for the system.
<span class='line'>291</span>  * @return {cc.keyboardDispatcher}
<span class='line'>292</span>  */</span><span class="WHIT">
<span class='line'>293</span> </span><span class="NAME">cc.KeyboardDispatcher.getInstance</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">cc.keyboardDispatcher</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">        </span><span class="NAME">cc.keyboardDispatcher</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">cc.KeyboardDispatcher</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT">        </span><span class="COMM">//make canvas focusable</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT">        </span><span class="NAME">cc.canvas.setAttribute</span><span class="PUNC">(</span><span class="STRN">'tabindex'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>298</span> </span><span class="WHIT">        </span><span class="NAME">cc.canvas.style.outline</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'none'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT">        </span><span class="NAME">cc.canvas.style.cursor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'default'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT">        </span><span class="NAME">cc.canvas.addEventListener</span><span class="PUNC">(</span><span class="STRN">"keydown"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT">            </span><span class="NAME">cc.keyboardDispatcher.dispatchKeyboardMSG</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">        </span><span class="NAME">cc.canvas.addEventListener</span><span class="PUNC">(</span><span class="STRN">"keyup"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">            </span><span class="NAME">cc.keyboardDispatcher.dispatchKeyboardMSG</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">cc.keyboardDispatcher</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>308</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>309</span> 
<span class='line'>310</span> </span><span class="COMM">/**
<span class='line'>311</span>  * Release the shared cc.KeyboardDispatcher object from the system.
<span class='line'>312</span>  */</span><span class="WHIT">
<span class='line'>313</span> </span><span class="NAME">cc.KeyboardDispatcher.purgeSharedDispatcher</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">cc.keyboardDispatcher</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>315</span> </span><span class="WHIT">        </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">cc.keyboardDispatcher</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT">        </span><span class="NAME">cc.keyboardDispatcher</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>317</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>318</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>319</span> </span></pre></body></html>